//
//  TCAudienceNavigate.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/7/3.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class TCAudienceNavigate: NSView {
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        self.setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() {
        self.addSubview(reloadView)
        reloadView.snp.makeConstraints { (make) in
            make.height.equalTo(30)
            make.right.equalToSuperview().offset(-10)
            make.top.equalTo(10)
            make.width.equalTo(30)
        }
        
        self.addSubview(left)
        left.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.top.equalTo(20)
            make.width.equalTo(150)
            make.bottom.equalToSuperview()
        }
        
        self.left.addSubview(themeLab)
        themeLab.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.left.equalTo(10)
            make.height.equalTo(28)
        }
        
        self.left.addSubview(statusLab)
        statusLab.snp.makeConstraints { (make) in
            make.top.equalTo(themeLab.snp.bottom).offset(5)
            make.left.equalTo(10)
            make.height.equalTo(16)
            make.width.equalTo(35)
        }
        
        self.left.addSubview(adcNumLab)
        adcNumLab.snp.makeConstraints { (make) in
            make.centerY.equalTo(statusLab)
            make.left.equalTo(50)
            make.height.equalTo(16)
        }
    }
    
    lazy var reloadView: KIcon = {
        let view = KIcon.init(data: KIconGroup.init(title: nil, image: "icon_back_home"))
        view.imagePosition = .left
        view.wantsLayer = true
        view.layer?.backgroundColor = color_gray(30).withAlphaComponent(0.9).cgColor
        view.layer?.cornerRadius = 3
        view.layer?.masksToBounds = true
        view.tap = { _ in
            TCGirdRender.shared().renderer.reloadData(noLocal:true)
            TCGirdRender.shared().renderer.swapt(focusId: Td.sh().cloud.focusId)
        }
        return view
    }()
    
    lazy var left: NSView = {
        let view = NSView.init()
        view.wantsLayer = true
        view.layer?.backgroundColor = color_dark.withAlphaComponent(0.9).cgColor
        view.layer?.cornerRadius = 10
        return view
    }()
    
    lazy var themeLab: NSLabel = {
        let lab = NSLabel.label(title: "直播活动", textColor: color_gray(230), font: NSFont.systemFont(ofSize: 22))
        lab.sizeToFit()
        return lab
    }()
    
    lazy var adcNumLab: NSLabel = {
        let lab = NSLabel.label(title: "\(Td.sh().member) 人正在观看", textColor: color_gray(230), font: NSFont.systemFont(ofSize: 13))
        lab.sizeToFit()
        return lab
    }()
    lazy var statusLab: NSLabel = {
        let lab = NSLabel.label(title: "直播", textColor: color_gray(230), font: NSFont.systemFont(ofSize: 11))
        lab.alignment = .center
        lab.backgroundColor = color_red85
        return lab
    }()
}
